from airtest.core.api import *
from Base.BaseSettings import PictureBaiduDIR
from Base.AirtestLib import uuid_report
from Common.case.templateCase import TemplateCase, BaseCase
from Common.utils.com_utils import AirTaskData

# 调试模式下 使用BaseCase
# class BaiduSearchbox(BaseCase):
# 服务端项目下 使用 TemplateCase
class BaiduSearchbox(TemplateCase):

    title = "百度"
    author = "panyzh"


    @uuid_report("同意协议", title=title, author=author)
    def test_1_enter_protocol(self):

        # 等待欢迎框出现
        wait(Template(fr"{PictureBaiduDIR}欢迎框.png"))

        # 点击同意
        touch(Template(fr"{PictureBaiduDIR}同意.png"))

    @uuid_report("其他测试Case", title=title, author=author)
    def test_2_1_other_case(self):
        pass

    @uuid_report("覆盖安装", title=title, author=author)
    def test_8_cover(self):
        package_path = AirTaskData['package_path']
        package_name = AirTaskData['package_name']

        # 安装应用
        install(package_path, install_options=["-r", "-t"])
        sleep(1)
        # 启动应用
        start_app(package_name)

        sleep(30)
        # 登录成功，不出现 用户协议弹窗
        assert_not_exists(Template(fr"{PictureBaiduDIR}欢迎框.png"))